home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-07-25 | 31.7 KB | 1,016 lines |
- Newsgroups: comp.sources.misc
- From: Martin Fouts <fouts@clipper.ingr.com>
- Subject: v21i037: cloops - Livermore Loops in C, Part02/03
- Message-ID: <1991Jul25.020719.28313@sparky.IMD.Sterling.COM>
- X-Md4-Signature: cc07cf600ac399272ffcdec1003d37b6
- Date: Thu, 25 Jul 1991 02:07:19 GMT
- Approved: kent@sparky.imd.sterling.com
-
- Submitted-by: Martin Fouts <fouts@clipper.ingr.com>
- Posting-number: Volume 21, Issue 37
- Archive-name: cloops/part02
- Environment: Cray2, Alliant Convex Amdahl, Sun, SGI
-
- ----- cut here for Part02
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 2 (of 3)."
- # Contents: COPYING baseline.c kernel.c
- # Wrapped by fouts@bozeman on Sun Jul 21 18:23:20 1991
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'COPYING' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'COPYING'\"
- else
- echo shar: Extracting \"'COPYING'\" \(12488 characters\)
- sed "s/^X//" >'COPYING' <<'END_OF_FILE'
- X
- X GNU GENERAL PUBLIC LICENSE
- X Version 1, February 1989
- X
- X Copyright (C) 1989 Free Software Foundation, Inc.
- X 675 Mass Ave, Cambridge, MA 02139, USA
- X Everyone is permitted to copy and distribute verbatim copies
- X of this license document, but changing it is not allowed.
- X
- X Preamble
- X
- X The license agreements of most software companies try to keep users
- Xat the mercy of those companies. By contrast, our General Public
- XLicense is intended to guarantee your freedom to share and change free
- Xsoftware--to make sure the software is free for all its users. The
- XGeneral Public License applies to the Free Software Foundation's
- Xsoftware and to any other program whose authors commit to using it.
- XYou can use it for your programs, too.
- X
- X When we speak of free software, we are referring to freedom, not
- Xprice. Specifically, the General Public License is designed to make
- Xsure that you have the freedom to give away or sell copies of free
- Xsoftware, that you receive source code or can get it if you want it,
- Xthat you can change the software or use pieces of it in new free
- Xprograms; and that you know you can do these things.
- X
- X To protect your rights, we need to make restrictions that forbid
- Xanyone to deny you these rights or to ask you to surrender the rights.
- XThese restrictions translate to certain responsibilities for you if you
- Xdistribute copies of the software, or if you modify it.
- X
- X For example, if you distribute copies of a such a program, whether
- Xgratis or for a fee, you must give the recipients all the rights that
- Xyou have. You must make sure that they, too, receive or can get the
- Xsource code. And you must tell them their rights.
- X
- X We protect your rights with two steps: (1) copyright the software, and
- X(2) offer you this license which gives you legal permission to copy,
- Xdistribute and/or modify the software.
- X
- X Also, for each author's protection and ours, we want to make certain
- Xthat everyone understands that there is no warranty for this free
- Xsoftware. If the software is modified by someone else and passed on, we
- Xwant its recipients to know that what they have is not the original, so
- Xthat any problems introduced by others will not reflect on the original
- Xauthors' reputations.
- X
- X The precise terms and conditions for copying, distribution and
- Xmodification follow.
- X
- X GNU GENERAL PUBLIC LICENSE
- X TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
- X
- X 0. This License Agreement applies to any program or other work which
- Xcontains a notice placed by the copyright holder saying it may be
- Xdistributed under the terms of this General Public License. The
- X"Program", below, refers to any such program or work, and a "work based
- Xon the Program" means either the Program or any work containing the
- XProgram or a portion of it, either verbatim or with modifications. Each
- Xlicensee is addressed as "you".
- X
- X 1. You may copy and distribute verbatim copies of the Program's source
- Xcode as you receive it, in any medium, provided that you conspicuously and
- Xappropriately publish on each copy an appropriate copyright notice and
- Xdisclaimer of warranty; keep intact all the notices that refer to this
- XGeneral Public License and to the absence of any warranty; and give any
- Xother recipients of the Program a copy of this General Public License
- Xalong with the Program. You may charge a fee for the physical act of
- Xtransferring a copy.
- X
- X 2. You may modify your copy or copies of the Program or any portion of
- Xit, and copy and distribute such modifications under the terms of Paragraph
- X1 above, provided that you also do the following:
- X
- X a) cause the modified files to carry prominent notices stating that
- X you changed the files and the date of any change; and
- X
- X b) cause the whole of any work that you distribute or publish, that
- X in whole or in part contains the Program or any part thereof, either
- X with or without modifications, to be licensed at no charge to all
- X third parties under the terms of this General Public License (except
- X that you may choose to grant warranty protection to some or all
- X third parties, at your option).
- X
- X c) If the modified program normally reads commands interactively when
- X run, you must cause it, when started running for such interactive use
- X in the simplest and most usual way, to print or display an
- X announcement including an appropriate copyright notice and a notice
- X that there is no warranty (or else, saying that you provide a
- X warranty) and that users may redistribute the program under these
- X conditions, and telling the user how to view a copy of this General
- X Public License.
- X
- X d) You may charge a fee for the physical act of transferring a
- X copy, and you may at your option offer warranty protection in
- X exchange for a fee.
- X
- XMere aggregation of another independent work with the Program (or its
- Xderivative) on a volume of a storage or distribution medium does not bring
- Xthe other work under the scope of these terms.
- X
- X 3. You may copy and distribute the Program (or a portion or derivative of
- Xit, under Paragraph 2) in object code or executable form under the terms of
- XParagraphs 1 and 2 above provided that you also do one of the following:
- X
- X a) accompany it with the complete corresponding machine-readable
- X source code, which must be distributed under the terms of
- X Paragraphs 1 and 2 above; or,
- X
- X b) accompany it with a written offer, valid for at least three
- X years, to give any third party free (except for a nominal charge
- X for the cost of distribution) a complete machine-readable copy of the
- X corresponding source code, to be distributed under the terms of
- X Paragraphs 1 and 2 above; or,
- X
- X c) accompany it with the information you received as to where the
- X corresponding source code may be obtained. (This alternative is
- X allowed only for noncommercial distribution and only if you
- X received the program in object code or executable form alone.)
- X
- XSource code for a work means the preferred form of the work for making
- Xmodifications to it. For an executable file, complete source code means
- Xall the source code for all modules it contains; but, as a special
- Xexception, it need not include source code for modules which are standard
- Xlibraries that accompany the operating system on which the executable
- Xfile runs, or for standard header files or definitions files that
- Xaccompany that operating system.
- X
- X 4. You may not copy, modify, sublicense, distribute or transfer the
- XProgram except as expressly provided under this General Public License.
- XAny attempt otherwise to copy, modify, sublicense, distribute or transfer
- Xthe Program is void, and will automatically terminate your rights to use
- Xthe Program under this License. However, parties who have received
- Xcopies, or rights to use copies, from you under this General Public
- XLicense will not have their licenses terminated so long as such parties
- Xremain in full compliance.
- X
- X 5. By copying, distributing or modifying the Program (or any work based
- Xon the Program) you indicate your acceptance of this license to do so,
- Xand all its terms and conditions.
- X
- X 6. Each time you redistribute the Program (or any work based on the
- XProgram), the recipient automatically receives a license from the original
- Xlicensor to copy, distribute or modify the Program subject to these
- Xterms and conditions. You may not impose any further restrictions on the
- Xrecipients' exercise of the rights granted herein.
- X
- X 7. The Free Software Foundation may publish revised and/or new versions
- Xof the General Public License from time to time. Such new versions will
- Xbe similar in spirit to the present version, but may differ in detail to
- Xaddress new problems or concerns.
- X
- XEach version is given a distinguishing version number. If the Program
- Xspecifies a version number of the license which applies to it and "any
- Xlater version", you have the option of following the terms and conditions
- Xeither of that version or of any later version published by the Free
- XSoftware Foundation. If the Program does not specify a version number of
- Xthe license, you may choose any version ever published by the Free Software
- XFoundation.
- X
- X 8. If you wish to incorporate parts of the Program into other free
- Xprograms whose distribution conditions are different, write to the author
- Xto ask for permission. For software which is copyrighted by the Free
- XSoftware Foundation, write to the Free Software Foundation; we sometimes
- Xmake exceptions for this. Our decision will be guided by the two goals
- Xof preserving the free status of all derivatives of our free software and
- Xof promoting the sharing and reuse of software generally.
- X
- X NO WARRANTY
- X
- X 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
- XFOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
- XOTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
- XPROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
- XOR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- XMERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
- XTO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
- XPROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
- XREPAIR OR CORRECTION.
- X
- X 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
- XWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
- XREDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
- XINCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
- XOUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
- XTO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
- XYOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
- XPROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
- XPOSSIBILITY OF SUCH DAMAGES.
- X
- X END OF TERMS AND CONDITIONS
- X
- X Appendix: How to Apply These Terms to Your New Programs
- X
- X If you develop a new program, and you want it to be of the greatest
- Xpossible use to humanity, the best way to achieve this is to make it
- Xfree software which everyone can redistribute and change under these
- Xterms.
- X
- X To do so, attach the following notices to the program. It is safest to
- Xattach them to the start of each source file to most effectively convey
- Xthe exclusion of warranty; and each file should have at least the
- X"copyright" line and a pointer to where the full notice is found.
- X
- X <one line to give the program's name and a brief idea of what it does.>
- X Copyright (C) 19yy <name of author>
- X
- X This program is free software; you can redistribute it and/or modify
- X it under the terms of the GNU General Public License as published by
- X the Free Software Foundation; either version 1, or (at your option)
- X any later version.
- X
- X This program is distributed in the hope that it will be useful,
- X but WITHOUT ANY WARRANTY; without even the implied warranty of
- X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X GNU General Public License for more details.
- X
- X You should have received a copy of the GNU General Public License
- X along with this program; if not, write to the Free Software
- X Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X
- XAlso add information on how to contact you by electronic and paper mail.
- X
- XIf the program is interactive, make it output a short notice like this
- Xwhen it starts in an interactive mode:
- X
- X Gnomovision version 69, Copyright (C) 19xx name of author
- X Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- X This is free software, and you are welcome to redistribute it
- X under certain conditions; type `show c' for details.
- X
- XThe hypothetical commands `show w' and `show c' should show the
- Xappropriate parts of the General Public License. Of course, the
- Xcommands you use may be called something other than `show w' and `show
- Xc'; they could even be mouse-clicks or menu items--whatever suits your
- Xprogram.
- X
- XYou should also get your employer (if you work as a programmer) or your
- Xschool, if any, to sign a "copyright disclaimer" for the program, if
- Xnecessary. Here a sample; alter the names:
- X
- X Yoyodyne, Inc., hereby disclaims all copyright interest in the
- X program `Gnomovision' (a program to direct compilers to make passes
- X at assemblers) written by James Hacker.
- X
- X <signature of Ty Coon>, 1 April 1989
- X Ty Coon, President of Vice
- X
- XThat's all there is to it!
- END_OF_FILE
- if test 12488 -ne `wc -c <'COPYING'`; then
- echo shar: \"'COPYING'\" unpacked with wrong size!
- fi
- # end of 'COPYING'
- fi
- if test -f 'baseline.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'baseline.c'\"
- else
- echo shar: Extracting \"'baseline.c'\" \(4776 characters\)
- sed "s/^X//" >'baseline.c' <<'END_OF_FILE'
- X/*
- X * This file is part of the Livermore Loops transliteration into C.
- X * Copyright (C) 1991 by Martin Fouts
- X *
- X * This program is free software; you can redistribute it and/or modify
- X * it under the terms of the GNU General Public License as published by
- X * the Free Software Foundation; either version 1, or (at your option)
- X * any later version.
- X *
- X * This program is distributed in the hope that it will be useful,
- X * but WITHOUT ANY WARRANTY; without even the implied warranty of
- X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X * GNU General Public License for more details.
- X *
- X * You should have received a copy of the GNU General Public License
- X * along with this program; if not, write to the Free Software
- X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X */
- X
- X#include <stdio.h>
- X
- X#define BASENAME "baseline.dat"
- X#define NTESTS 24
- X
- X#define TRUE 1
- X#define FALSE 0
- X
- X#define PERCENT 0.05
- X
- X#define abs(a) (((a) < 0) ? -(a) : (a))
- X
- XFILE *fopen();
- Xchar *fgets();
- X
- Xdouble err(a,b)
- Xdouble a, b;
- X{
- X if (a == 0.0) {
- X return(b);
- X } else {
- X return(abs(b-a)/a);
- X }
- X}
- X
- Xmain(argc,argv)
- Xint argc;
- Xchar *argv[];
- X{
- X int i;
- X int errors;
- X char *basename, *testname;
- X FILE *baseline, *testdata;
- X int kern, span;
- X double percent = PERCENT;
- X double flops, weight, sum;
- X int b_kern, b_flag[NTESTS];
- X int b_span[NTESTS];
- X double b_flops[NTESTS], b_weight[NTESTS], b_sum[NTESTS];
- X int t_kern, t_flag[NTESTS];
- X int t_span[NTESTS];
- X double t_flops[NTESTS], t_weight[NTESTS], t_sum[NTESTS];
- X double dummy, worst;
- X char buffer[BUFSIZ];
- X
- X if (argc == 2) {
- X basename = BASENAME;
- X testname = argv[1];
- X } else {
- X if (argc == 3) {
- X basename = BASENAME;
- X sscanf(argv[2],"%f",&percent);
- X printf("Using percent = %f\n", percent);
- X testname = argv[1];
- X } else {
- X if (argc == 4) {
- X basename = argv[3];
- X sscanf(argv[2],"%f",&percent);
- X testname = argv[1];
- X } else {
- X fprintf(stderr,"Usage: %s testname [percent [basename]]\n", argv[0]);
- X }
- X }
- X }
- X
- X if ((baseline = fopen(basename,"r")) == NULL) {
- X fprintf(stderr,"Error attempting to open %s", basename);
- X perror("");
- X exit(1);
- X }
- X
- X if ((testdata = fopen(testname,"r")) == NULL) {
- X fprintf(stderr,"Error attempting to open %s", testname);
- X perror("");
- X exit(1);
- X }
- X
- X for (i = 0; i < NTESTS; i++) {
- X b_flag[i] = FALSE;
- X t_flag[i] = FALSE;
- X }
- X
- X while (fgets(buffer,BUFSIZ,baseline) != NULL) {
- X sscanf(buffer,"%d %e %e %e %d %e %e\n", &kern, &flops, &dummy,
- X &dummy, &span, &weight, &sum);
- X if ((kern < 1) || (kern > NTESTS)) {
- X fprintf(stderr,"Ignoring data from baseline:\n");
- X fprintf(stderr,"%s\n", buffer);
- X }
- X b_kern = kern - 1;
- X b_flag[b_kern] = TRUE;
- X b_span[b_kern] = span;
- X b_flops[b_kern] = flops;
- X b_weight[b_kern] = weight;
- X b_sum[b_kern] = sum;
- X }
- X
- X while (fgets(buffer,BUFSIZ,testdata) != NULL) {
- X sscanf(buffer,"%d %e %e %e %d %e %e\n", &kern, &flops, &dummy,
- X &dummy, &span, &weight, &sum);
- X if ((kern < 1) || (kern > NTESTS)) {
- X fprintf(stderr,"Ignoring data from baseline:\n");
- X fprintf(stderr,"%s\n", buffer);
- X }
- X t_kern = kern - 1;
- X t_flag[t_kern] = TRUE;
- X t_span[t_kern] = span;
- X t_flops[t_kern] = flops;
- X t_weight[t_kern] = weight;
- X t_sum[t_kern] = sum;
- X }
- X
- X for (i = 0; i < NTESTS; i++) {
- X if (!b_flag[i]) {
- X if (t_flag[i]) {
- X fprintf(stdout,"Kernel %d: No baseline. Test data.\n",i+1);
- X } else {
- X fprintf(stdout,"Kernel %d: No baseline. No test data.\n",i+1);
- X }
- X } else {
- X if (!t_flag[i]) {
- X fprintf(stdout,"Kernel %d: Baseline. No test data.\n",i+1);
- X } else {
- X
- X errors = 0;
- X worst = 0.0;
- X
- X dummy = err(b_flops[i],t_flops[i]);
- X if (dummy > percent) {
- X fprintf(stdout,"Kernel %d: Flops: baseline = %g, test = %g\n",
- X i+1, b_flops[i], t_flops[i]);
- X errors++;
- X }
- X if (dummy > worst) worst = dummy;
- X
- X dummy = err((double)b_span[i],(double)t_span[i]);
- X if (dummy > percent) {
- X fprintf(stdout,"Kernel %d: Span: baseline = %d, test = %d\n",
- X i+1, b_span[i], t_span[i]);
- X errors++;
- X }
- X if (dummy > worst) worst = dummy;
- X
- X dummy = err(b_weight[i],t_weight[i]);
- X if (dummy > percent) {
- X fprintf(stdout,"Kernel %d: Weight: baseline = %g, test = %g\n",
- X i+1, b_weight[i], t_weight[i]);
- X errors++;
- X }
- X if (dummy > worst) worst = dummy;
- X
- X dummy = err(b_sum[i],t_sum[i]);
- X if (dummy > percent) {
- X fprintf(stdout,"Kernel %d: Sum: baseline = %g, test = %g\n",
- X i+1, b_sum[i], t_sum[i]);
- X errors++;
- X }
- X if (dummy > worst) worst = dummy;
- X
- X/*
- X if (errors == 0) {
- X fprintf(stdout,"Kernel %d: Baseline and Test agree.\n", i+1);
- X } else {
- X fprintf(stdout,"Kernel %d: Baseline and Test disagree %d times.\n",
- X i+1, errors);
- X }
- X*/
- X }
- X }
- X }
- X
- X exit(0);
- X}
- X
- END_OF_FILE
- if test 4776 -ne `wc -c <'baseline.c'`; then
- echo shar: \"'baseline.c'\" unpacked with wrong size!
- fi
- # end of 'baseline.c'
- fi
- if test -f 'kernel.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'kernel.c'\"
- else
- echo shar: Extracting \"'kernel.c'\" \(11686 characters\)
- sed "s/^X//" >'kernel.c' <<'END_OF_FILE'
- X/*
- X * This file is part of the Livermore Loops transliteration into C.
- X * Copyright (C) 1991 by Martin Fouts
- X *
- X * This program is free software; you can redistribute it and/or modify
- X * it under the terms of the GNU General Public License as published by
- X * the Free Software Foundation; either version 1, or (at your option)
- X * any later version.
- X *
- X * This program is distributed in the hope that it will be useful,
- X * but WITHOUT ANY WARRANTY; without even the implied warranty of
- X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X * GNU General Public License for more details.
- X *
- X * You should have received a copy of the GNU General Public License
- X * along with this program; if not, write to the Free Software
- X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X */
- X
- X#include "types.h"
- X#include "externs.h"
- X
- X#define isign(i,j) ((j < 0) ? -i : i)
- X#define mod2n(i,j) (i % j) + (j / 2) - isign((j/2),i)
- X
- X#define amax1(a,b) ((a < b) ? b : a)
- X#define amin1(a,b) ((a > b) ? b : a)
- X
- X#define TEST(x) if ((DoTest & (1<<(x-1))) == (1<<(x-1)))
- X
- Xextern long int DoTest;
- X
- XVoid test();
- Xdouble sqrt();
- Xdouble exp();
- X
- XVoid kernel()
- X{
- X Int i, l, k, il, ipntp, ipnt, lw, j, nl1, nl2, kx, ky, ip, i1, j1;
- X Int i2, j2, nr, nz;
- X Int ii, lb, j4, ink;
- X Int kn, jn, kb5i;
- X Float xtemp;
- X
- X test((Int)0);
- X TEST(1) {
- X for (l = 0; l < lp; l++)
- X for (k = 0; k < n; k++)
- X x[k]= q + y[k]*(r*z[k+10] + t*z[k+11]);
- X}
- X test((Int)1);
- X TEST(2) {
- X for (l = 0; l < lp; l++) {
- X il= n;
- X ipntp= 0;
- X l_222: ipnt= ipntp;
- X ipntp= ipntp+il;
- X il= il/2;
- X i= ipntp;
- X for (k = ipnt+1; k < ipntp; k += 2) {
- X i= i+1;
- X x[i]= x[k] - v[k]*x[k-1] - v[k+1]*x[k+1];
- X }
- X if( il>1) goto l_222;
- X }
- X}
- X test((Int)2);
- X TEST(3) {
- X for (l = 0; l < lp; l++) {
- X q = 0.0;
- X for (k = 0; k < n; k++) {
- X q += z[k]*x[k];
- X }
- X }
- X}
- X test((Int)3);
- X TEST(4) {
- X m= (1001-7)/2;
- X for (l = 0; l < lp; l++) {
- X for (k = 6; k < 1001; k += m) {
- X lw= k-6;
- X for (j = 4; j < n; j += 5) {
- X x[k-1]= x[k-1] - x[lw]*y[j];
- X lw= lw+1;
- X }
- X x[k-1]= y[4]*x[k-1];
- X }
- X }
- X}
- X test((Int)4);
- X TEST(5) {
- X for (l = 0; l < lp; l++)
- X for (i = 1; i < n; i++)
- X x[i]= z[i]*(y[i] - x[i-1]);
- X}
- X test((Int)5);
- X TEST(6) {
- X for (l = 0; l < lp; l++)
- X for (i = 1; i < n; i++)
- X for (k = 0; k < i; k++)
- X w[i] += b[i][k] * w[i-k-1];
- X}
- X test((Int)6);
- X TEST(7) {
- X for (l = 0; l < lp; l++)
- X for (k = 0; k < n; k++)
- X x[k]= u[k ] + r*( z[k ] + r*y[k ]) +
- X t*( u[k+3] + r*( u[k+2] + r*u[k+1]) +
- X t*( u[k+6] + r*( u[k+5] + r*u[k+4])));
- X}
- X test((Int)7);
- X TEST(8) {
- X for (l = 0; l < lp; l++) {
- X nl1 = 0;
- X nl2 = 1;
- X for (kx = 1; kx < 3; kx++) {
- X for (ky = 1; ky < n; ky++) {
- X du1[ky]= u1[kx][ky+1][nl1] - u1[kx][ky-1][nl1];
- X du2[ky]= u2[kx][ky+1][nl1] - u2[kx][ky-1][nl1];
- X du3[ky]= u3[kx][ky+1][nl1] - u3[kx][ky-1][nl1];
- X u1[kx][ky][nl2]= u1[kx][ky][nl1]+a11*du1[ky]+a12*du2[ky]+a13*du3[ky]+
- X sig*(u1[kx+1][ky][nl1]-2.*u1[kx][ky][nl1]+u1[kx-1][ky][nl1]);
- X u2[kx][ky][nl2]= u2[kx][ky][nl1]+a21*du1[ky]+a22*du2[ky]+a23*du3[ky]+
- X sig*(u2[kx+1][ky][nl1]-2.*u2[kx][ky][nl1]+u2[kx-1][ky][nl1]);
- X u3[kx][ky][nl2]= u3[kx][ky][nl1]+a31*du1[ky]+a32*du2[ky]+a33*du3[ky]+
- X sig*(u3[kx+1][ky][nl1]-2.*u3[kx][ky][nl1]+u3[kx-1][ky][nl1]);
- X }
- X }
- X }
- X}
- X test((Int)8);
- X TEST(9) {
- X for (l = 0; l < lp; l++)
- X for (i = 0; i < n; i++)
- X px[ 0][i]= dm28*px[12][i] + dm27*px[11][i] + dm26*px[10][i] +
- X dm25*px[9][i] + dm24*px[8][i] + dm23*px[7][i] +
- X dm22*px[6][i] + c0*(px[4][i] + px[5][i])+ px[ 2][i];
- X}
- X test((Int)9);
- X TEST(10) {
- X for (l = 0; l < lp; l++) {
- X for (i = 0; i < n; i++) {
- X ar = cx[4][i];
- X br = ar - px[4][i];
- X px[4][i] = ar;
- X cr = br - px[5][i];
- X px[5][i] = br;
- X ar = cr - px[6][i];
- X px[6][i] = cr;
- X br = ar - px[7][i];
- X px[7][i] = ar;
- X cr = br - px[8][i];
- X px[8][i] = br;
- X ar = cr - px[9][i];
- X px[9][i]= cr;
- X br = ar - px[10][i];
- X px[10][i]= ar;
- X cr = br - px[11][i];
- X px[11][i]= br;
- X px[13][i]= cr - px[12][i];
- X px[12][i]= cr;
- X }
- X }
- X}
- X test((Int)10);
- X TEST(11) {
- X for (l = 0; l < lp; l++) {
- X x[0]= y[0];
- X for (k = 1; k < n; k++) {
- X x[k]= x[k-1] + y[k];
- X }
- X }
- X}
- X test((Int)11);
- X TEST(12) {
- X for (l = 0; l < lp; l++) {
- X for (k = 0; k < n; k++) {
- X x[k]= y[k+1] - y[k];
- X }
- X }
- X}
- X test((Int)12);
- X TEST(13) {
- X for (l = 0; l < lp; l++) {
- X for (ip = 0; ip < n; ip++) {
- X i1= p[0][ip];
- X j1= p[1][ip];
- X i1= mod2n(i1,64);
- X j1= mod2n(j1,64);
- X p[2][ip]= p[2][ip] + b[i1][j1];
- X p[3][ip]= p[3][ip] + c[i1][j1];
- X p[0][ip]= p[0][ip] + p[2][ip];
- X p[1][ip]= p[1][ip] + p[3][ip];
- X i2= p[0][ip];
- X j2= p[1][ip];
- X i2= mod2n(i2,64) - 1;
- X j2= mod2n(j2,64) - 1;
- X p[0][ip]= p[0][ip] + y[i2+32];
- X p[1][ip]= p[1][ip] + z[j2+32];
- X i2= i2 + e[i2+32];
- X j2= j2 + f[j2+32];
- X h[i2][j2]= h[i2][j2] + 1.0;
- X }
- X }
- X}
- X test((Int)13);
- X TEST(14) {
- X for (l = 0; l < lp; l++) {
- X for (k = 0; k < n; k++) {
- X ix[k]= (Int) grd[k];
- X xi[k]= (Float) ix[k];
- X ex1[k]= ex [ ix[k]-1 ];
- X dex1[k]= dex [ ix[k]-1 ];
- X }
- X for (k = 0; k < n; k++) {
- X vx[k]= vx[k] + ex1[k] + (xx[k] - xi[k])*dex1[k];
- X xx[k]= xx[k] + vx[k] + flx;
- X ir[k]= xx[k];
- X rx[k]= xx[k] - ir[k];
- X ir[k]= mod2n( ir[k],512) + 1;
- X xx[k]= rx[k] + ir[k];
- X }
- X for (k = 0; k < n; k++) {
- X rh[ir[k]-1]= rh[ir[k]-1] + 1.0 - rx[k];
- X rh[ir[k]]= rh[ir[k]] + rx[k];
- X }
- X }
- X}
- X test((Int)14);
- X TEST(15) {
- X for (l = 0; l < lp; l++) {
- X nr= 7;
- X nz= n;
- X ar= 0.053;
- X br= 0.073;
- X for (j = 1; j < nr; j++) {
- X for (k = 1; k < nz; k++) {
- X if (j >= (nr-1)) {
- X vy[k][j] = 0.0;
- X continue;
- X }
- X if (vh[k][j+1] > vh[k][j]) {
- X t = ar;
- X } else {
- X t = br;
- X }
- X if (vf[k][j] < vf[k-1][j]) {
- X r= amax1(vh[k-1][j], vh[k-1][j+1]);
- X s= vf[k-1][j];
- X } else {
- X r= amax1( vh[k][j], vh[k][j+1]);
- X s= vf[k][j];
- X }
- X vy[k][j]= sqrt((double) (vg[k][j]*vg[k][j] +r*r))*t/s;
- X if (k >= (nz-1)) {
- X vs[k][j] = 0.;
- X continue;
- X }
- X if (vf[k][j] < vf[k][j-1]) {
- X r= amax1( vg[k][j-1], vg[k+1][j-1]);
- X s= vf[k][j-1];
- X t= br;
- X } else {
- X r= amax1( vg[k][j], vg[k+1][j]);
- X s= vf[k][j];
- X t= ar;
- X }
- X vs[k][j]= sqrt((double) (vh[k][j]*vh[k][j] +r*r))*t/s;
- X }
- X }
- X }
- X}
- X test((Int)15);
- X TEST(16) {
- X ii= n/3;
- X lb= ii+ii;
- X k2= 0;
- X k3= 0;
- X for (l = 0; l < lp; l++) {
- X m= 0;
- X i1= m;
- Xl_410:
- X j2= ((n+n)*m) + 1;
- X for (k = 0; k < n; k++) {
- X k2= k2+1;
- X j4= j2+k+k+1;
- X j5= zone[j4];
- X if (j5-n+1 < 0) goto l_420;
- X if (j5-n+1 == 0) goto l_475;
- X goto l_450;
- Xl_415:
- X if (j5-n+ii+1 < 0) goto l_430;
- X if (j5-n+ii+1 == 0) goto l_425;
- X goto l_425;
- Xl_420:
- X if (j5-n+lb+1 < 0) goto l_435;
- X if (j5-n+lb+1 == 0) goto l_415;
- X goto l_415;
- Xl_425:
- X if (plan[j5] - r < 0) goto l_445;
- X if (plan[j5] - r == 0) goto l_480;
- X goto l_440;
- Xl_430:
- X if (plan[j5] - s < 0) goto l_445;
- X if (plan[j5] - s == 0) goto l_480;
- X goto l_440;
- Xl_435:
- X if (plan[j5] - t < 0) goto l_445;
- X if (plan[j5] - t == 0) goto l_480;
- X goto l_440;
- Xl_440:
- X if (zone[j4-1]+1 < 0) goto l_455;
- X if (zone[j4-1]+1 == 0) goto l_485;
- X goto l_470;
- Xl_445:
- X if (zone[j4-1]+1 < 0) goto l_470;
- X if (zone[j4-1]+1 == 0) goto l_485;
- X goto l_455;
- Xl_450:
- X k3= k3+1;
- X xtemp = d[j5] - (d[j5-1]*((t-d[j5-2])*(t-d[j5-2])
- X +(s-d[j5-3])*(s-d[j5-3])
- X +(r-d[j5-4])*(r-d[j5-4])));
- X if (xtemp < 0) goto l_445;
- X if (xtemp == 0) goto l_480;
- X goto l_440;
- Xl_455:
- X m= m+1;
- X if (m < zone[0]) goto l_465;
- X if (m == zone[0]) goto l_465;
- X goto l_460;
- Xl_460:
- X m= 0;
- Xl_465:
- X if (i1 - m < 0) goto l_410;
- X if (i1 - m == 0) goto l_480;
- X goto l_410;
- Xl_470: ;
- X }
- Xl_475:
- Xl_480:
- Xl_485: ;
- X }
- X}
- X test((Int)16);
- X TEST(17) {
- X for (l = 0; l < lp; l++) {
- X i= n-1;
- X j= 0;
- X ink= -1;
- X scale= 5./3.;
- X xnm= 1./3.;
- X e6= 1.03/3.07;
- X goto l_61;
- Xl_60:
- X e6= xnm*vsp[i]+vstp[i];
- X vxne[i]= e6;
- X xnm= e6;
- X ve3[i]= e6;
- X i= i+ink;
- X if (i == j) goto l_62;
- Xl_61:
- X e3= xnm*vlr[i] +vlin[i];
- X xnei= vxne[i];
- X vxnd[i]= e6;
- X xnc= scale*e3;
- X if ( xnm >xnc) goto l_60;
- X if ( xnei>xnc) goto l_60;
- X ve3[i]= e3;
- X e6= e3+e3-xnm;
- X vxne[i]= e3+e3-xnei;
- X xnm= e6;
- X i= i+ink;
- X if ( i != j) goto l_61;
- Xl_62:
- X ;
- X }
- X}
- X test((Int)17);
- X TEST(18) {
- X for (l = 0; l < lp; l++) {
- X t= 0.0037;
- X s= 0.0041;
- X kn= 6;
- X jn= n;
- X for (k = 1; k < kn; k++) {
- X for (j = 1; j < jn; j++) {
- X za[j][k]= (zp[j-1][k+1]+zq[j-1][k+1]-zp[j-1][k]-zq[j-1][k])
- X *(zr[j][k]+zr[j-1][k])/(zm[j-1][k]+zm[j-1][k+1]);
- X zb[j][k]= (zp[j-1][k]+zq[j-1][k]-zp[j][k]-zq[j][k])
- X *(zr[j][k]+zr[j][k-1])/(zm[j][k]+zm[j-1][k]);
- X }
- X }
- X for (k = 1; k < kn; k++) {
- X for (j = 1; j < jn; j++) {
- X#ifdef CRAY2
- X temp1 = za[j][k] *(zz[j][k]-zz[j+1][k]);
- X temp2 = -za[j-1][k] *(zz[j][k]-zz[j-1][k]);
- X temp3 = -zb[j][k] *(zz[j][k]-zz[j][k-1]);
- X temp4 = zb[j][k+1] *(zz[j][k]-zz[j][k+1]);
- X zu[j][k] += s*(temp1+temp2+temp3+temp4);
- X temp1 =za[j][k]*(zr[j][k]-zr[j+1][k]);
- X temp2 = -za[j-1][k] *(zr[j][k]-zr[j-1][k]);
- X temp3 = -zb[j][k] *(zr[j][k]-zr[j][k-1]);
- X temp4 = zb[j][k+1] *(zr[j][k]-zr[j][k+1]);
- X zv[j][k] += s*(temp1+temp2+temp3+temp4);
- X#else
- X zu[j][k]= zu[j][k]+s*(za[j][k]*(zz[j][k]-zz[j+1][k])
- X -za[j-1][k] *(zz[j][k]-zz[j-1][k])
- X -zb[j][k] *(zz[j][k]-zz[j][k-1])
- X +zb[j][k+1] *(zz[j][k]-zz[j][k+1]));
- X zv[j][k]= zv[j][k]+s*(za[j][k]*(zr[j][k]-zr[j+1][k])
- X -za[j-1][k] *(zr[j][k]-zr[j-1][k])
- X -zb[j][k] *(zr[j][k]-zr[j][k-1])
- X +zb[j][k+1] *(zr[j][k]-zr[j][k+1]));
- X#endif
- X }
- X }
- X for (k = 1; k < kn; k++) {
- X for (j = 1; j < jn; j++) {
- X zr[j][k]= zr[j][k]+t*zu[j][k];
- X zz[j][k]= zz[j][k]+t*zv[j][k];
- X }
- X }
- X }
- X}
- X test((Int)18);
- X TEST(19) {
- X kb5i= 0;
- X for (l = 0; l < lp; l++) {
- X for (k = 0; k < n; k++) {
- X b5[k+kb5i]= sa[k] +stb5*sb[k];
- X stb5= b5[k+kb5i] -stb5;
- X }
- X for (i = 0; i < n; i++) {
- X k= n-i+1;
- X b5[k+kb5i]= sa[k] +stb5*sb[k];
- X stb5= b5[k+kb5i] -stb5;
- X }
- X }
- X}
- X test((Int)19);
- X TEST(20) {
- X for (l = 0; l < lp; l++) {
- X for (k = 0; k < n; k++) {
- X di= y[k]-g[k]/( xx[k]+dk);
- X dn= 0.2;
- X if ( di != 0.0) dn= amax1( 0.1,amin1( z[k]/di, 0.2));
- X x[k]= ((w[k]+v[k]*dn)* xx[k]+u[k])/(vx[k]+v[k]*dn);
- X xx[k+1]= (x[k]- xx[k])*dn+ xx[k];
- X }
- X }
- X}
- X test((Int)20);
- X TEST(21) {
- X for (l = 0; l < lp; l++)
- X for (i = 0; i < n; i++)
- X for (k = 0; k < n; k++)
- X for (j = 0; j < n; j++)
- X px[i][j]= px[i][j] +vy[i][k] * cx[k][j];
- X}
- X test((Int)21);
- X TEST(22) {
- X expmax= 20.0;
- X u[n-1]= 0.99*expmax*v[n-1];
- X for (l = 0; l < lp; l++) {
- X for (k = 0; k < n; k++) {
- X y[k]= u[k]/v[k];
- X w[k]= x[k]/( exp((double) y[k]) -1.0);
- X }
- X }
- X}
- X test((Int)22);
- X TEST(23) {
- X for (l = 0; l < lp; l++) {
- X for (j = 1; j < 6; j++) {
- X for (k = 1; k < n; k++) {
- X qa= za[k][j+1]*zr[k][j] +za[k][j-1]*zb[k][j] +
- X za[k+1][j]*zu[k][j] +za[k-1][j]*zv[k][j] +zz[k][j];
- X za[k][j]= za[k][j] +.175*(qa -za[k][j]);
- X }
- X }
- X }
- X}
- X test((Int)23);
- X TEST(24) {
- X x[ n/2]= -1.0e+10;
- X for (l = 0; l < lp; l++) {
- X m= 1;
- X for (k = 1; k < n; k++) {
- X if ( x[k] < x[m]) m= k;
- X }
- X }
- X}
- X test((Int)24);
- X return;
- X}
- END_OF_FILE
- if test 11686 -ne `wc -c <'kernel.c'`; then
- echo shar: \"'kernel.c'\" unpacked with wrong size!
- fi
- # end of 'kernel.c'
- fi
- echo shar: End of archive 2 \(of 3\).
- cp /dev/null ark2isdone
- MISSING=""
- for I in 1 2 3 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 3 archives.
- rm -f ark[1-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
-
- exit 0 # Just in case...
-